import {proxyModule} from 'tscommon/ts/vue/vm.ext';
import {TestQuery,TestDelete} from 'tsdomain/Test';
import {isError, fetchData} from 'tscommon/ts/tools/domain';

const {data,onCreate,onDestroy,onReady,onRefresh,onShow,events} = proxyModule({
  data(){
    return {
      list:[] as any[],
      errorInfo:[]
    };
  },
  events:{
    async fetchList(){
      const resp = await fetchData(TestQuery,{});
      if(!resp.flag){
        isError(resp,this);
        this.setter({'list':[]});
      }else{
        this.setter({'list':resp.data});
      }
    },
    async delTest(id:string[]){
      const resp = await fetchData(TestDelete,{id});
      if(!resp.flag){
        isError(resp,this);
        return false;
      }
      return true;
    }
  }
});
export  {data,onCreate,onDestroy,onReady,onRefresh,onShow,events};